home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / callback.001 / callback~ / callback / lib / dest / listdestinations.c < prev    next >
C/C++ Source or Header  |  1996-07-19  |  2KB  |  66 lines

  1.  
  2. #include "dest.p"
  3.  
  4. void listdestinations(int uid, int all)
  5. {
  6.     int
  7.     dindex,
  8.     gindex;
  9.     DESTINATION_
  10.     *dp;
  11.     unsigned 
  12.     groupidx;
  13.                         /* walk the groups */
  14.  
  15.                                                 /* all listings suppressed */
  16.     if (!givedestinations() && !givedirect() && !giveextra())
  17.         return;
  18.  
  19.     printf("\n"
  20.         "Callback destinations for %s:\n"
  21.         "----------------------------------\n", username(uid));
  22.  
  23.     for (gindex = 0; gindex < user_ngroups(uid); gindex++)
  24.     {                        
  25.     groupidx = usergroup(uid, gindex);      /* point to the group */
  26.  
  27.                         /* walk the destinations */
  28.     for (dindex = 0; dindex < ndestinations; dindex++)
  29.     {
  30.         dp = &destination[dindex];        /* use local pointer */
  31.  
  32.             switch (dp->mode)                   /* decide what to display */
  33.             {
  34.                 case extra_mode:                /* extra not wanted */
  35.                     if (!giveextra())
  36.                         continue;
  37.                 break;
  38.  
  39.                 case direct_mode:               /* direct not wanted */
  40.                     if (!givedirect())
  41.                         continue;
  42.                 break;
  43.  
  44.                 case phone_mode:                /* destinations not wanted */
  45.                     if (!givedestinations())
  46.                         continue;
  47.                 break;
  48.             }
  49.  
  50.         if (groupidx == dp->dgroup)        /* group found */
  51.         {
  52.         printf("%15s ", get_dname(dp->dname)); /* show dest. name */
  53.             
  54.         if (all)
  55.         {
  56.             printf("-- %s\n", dp->phonenr);
  57.             if (dp->filename)
  58.             printf("%15c    using %s\n", ' ', dp->filename);
  59.         }
  60.         else
  61.             printf("\n");
  62.         }
  63.     }
  64.     }
  65. }
  66.